Current Location: Home> Function Categories> date_sun_info

date_sun_info

Returns an array with information about the start/end of sunset/sunrise and dusk
Name:date_sun_info
Category:Date and time
Programming Language:php
One-line Description:Returns an array containing information about sunrise/sunset and dusk start/end of dusk for a specified date and location.

Definition and usage

date_sun_info() function returns an array containing information about sunrise/sunset and dusk start/end of dusk for a specified date and location.

Tip: See the date_sunrise() function to return the sunrise time of the specified date and place.

Tip: See the date_sunset() function to return the sunset time of the specified date and place.

Example

Return information about sunrise/sunset and dusk start/end at latitude 31.2283 and longitude 121.4755 on January 1, 2016:

 <?php
$sun_info = date_sun_info ( strtotime ( "2016-01-01" ) , 31.2283 , 121.4755 ) ;
foreach ( $sun_info as $key => $val )
  {
  echo " $key : " . date ( "H:i:s" , $val ) . "<br>" ;
  }
?>

Try it yourself

grammar

 date_sun_info ( timestamp , latitude , longitude ) ;
parameter describe
timestamp Required. Specify timestamp.
latitude Required. Required. latitude is specified, measured in degrees.
longitude Required. Required. Specify longitude, count in degrees.
Similar Functions
Popular Articles